#!/bin/bash

if [ $(id -u) = 0 ]
then
   echo "This script must not be run as root" 1>&2
   exit
fi

ROOT_PATH=$(cd $(dirname $0) && pwd);


if [ -d "$ROOT_PATH/guitar" ]
then

mkdir -p $HOME/guitar

for file in $ROOT_PATH/guitar/*.AppImage
do
	cp -f ${file} $HOME/guitar/
	break
done

for file in $HOME/guitar/*.AppImage
do
	chmod a+x ${file}

sh -c "echo '[Desktop Entry]
Type=Application
Name=Guitar
Exec='${file}'
Icon=document-save
Terminal=false
' > $HOME/Desktop/guitar.desktop"

	chmod a+x $HOME/Desktop/guitar.desktop
	#gio set $HOME/Desktop/guitar.desktop "metadata::trusted" yes
	gio set $HOME/Desktop/guitar.desktop "metadata::trusted" true

	break
done


fi
